import BasicLayout from '@/layouts/basic-layout';
// import monthlyplan from './modules/monthlyplan';
/**
 * 在主框架内显示
 */

const frameIn = [
    {
        path: '/',
        redirect: {
            name: 'planList'
        },
        component: BasicLayout,
        children: [
            {
                path: 'index',
                name: 'index',
                redirect: {
                    name: 'planList'
                }
            },
            // {
            //     path: 'log',
            //     name: 'log',
            //     meta: {
            //         title: '前端日志',
            //         auth: true
            //     },
            //     component: () => {
            //         return import('@/pages/system/log'); 
            //     }
            // },
            // 刷新页面 必须保留
            {
                path: 'refresh',
                name: 'refresh',
                hidden: true,
                component: {
                    beforeRouteEnter(to, from, next) {
                        next(instance => {
                            return instance.$router.replace(from.fullPath); 
                        });
                    },
                    render: h => {
                        return h(); 
                    }
                }
            },
            // 页面重定向 必须保留
            {
                path: 'redirect/:route*',
                name: 'redirect',
                hidden: true,
                component: {
                    beforeRouteEnter(to, from, next) {
                        next(instance => {
                            return instance.$router.replace(JSON.parse(from.params.route)); 
                        });
                    },
                    render: h => {
                        return h(); 
                    }
                }
            },
            // 网络月计划开始
            {
                path: 'monthlyplan/planList',
                name: 'planList',
                meta: {
                    auth: true,
                    title: '计划列表',
                    closable: false
                },
                component: () => {
                    return import('@/pages/monthlyplan/planList'); 
                }
            },
            {
                path: 'monthlyplan/projectReport',
                name: 'projectReport',
                meta: {
                    auth: true,
                    title: '项目报表',
                    closable: false
                },
                component: () => {
                    return import('@/pages/monthlyplan/projectReport'); 
                }
            },
            {
                path: 'monthlyplan/schedule',
                name: 'schedule',
                meta: {
                    auth: true,
                    title: '进度表',
                    closable: false
                },
                component: () => {
                    return import('@/pages/monthlyplan/schedule'); 
                }
            },
            // 网络月计划结束
            // 数据统计
            {
                path: 'statistical/ipsearch',
                name: 'ipsearch',
                meta: {
                    auth: true,
                    title: 'IP段搜索',
                    closable: false
                },
                component: () => {
                    return import('@/pages/statistical/ipsearch'); 
                }
            },
            {
                path: 'statistical/wordreport',
                name: 'wordreport',
                meta: {
                    auth: true,
                    title: '搜索词报表',
                    closable: false
                },
                component: () => {
                    return import('@/pages/statistical/wordreport'); 
                }
            },
            // 工作状态衡量
            {
                path: 'workload',
                name: 'workload',
                meta: {
                    auth: true,
                    title: '工作状态衡量',
                    closable: false
                },
                component: () => {
                    return import('@/pages/workload'); 
                }
            },
            // 通话时段统计
            {
                path: 'call',
                name: 'call',
                meta: {
                    auth: true,
                    title: '通话时段统计',
                    closable: false
                },
                component: () => {
                    return import('@/pages/call'); 
                }
            },
            {
                path: 'clueimport',
                name: 'clueimport',
                meta: {
                    auth: true,
                    title: '线索导入',
                    closable: false
                },
                component: () => {
                    return import('@/pages/clueImport'); 
                }
            },
            {
                path: 'channelreport',
                name: 'channelreport',
                meta: {
                    auth: true,
                    title: '渠道分析',
                    closable: false
                },
                component: () => {
                    return import('@/pages/channelreport'); 
                }
            },
            {
                path: 'statementaccount',
                name: 'statementaccount',
                meta: {
                    auth: true,
                    title: '财务对账单',
                    closable: false
                },
                component: () => {
                    return import('@/pages/statementaccount'); 
                }
            }
        ]
    },
    // monthlyplan
];

/**
 * 在主框架之外显示
 */

const frameOut = [
    // 登录
    {
        path: '/login',
        name: 'login',
        meta: {
            title: '$t:page.login.title'
        },
        component: () => {
            return import('@/pages/account/login'); 
        }
    },
    // 注册
    {
        path: '/register',
        name: 'register',
        meta: {
            title: '$t:page.register.title'
        },
        component: () => {
            return import('@/pages/account/register'); 
        }
    },
    // 注册结果
    {
        path: '/register/result',
        name: 'register-result',
        meta: {
            auth: true,
            title: '注册结果'
        },
        component: () => {
            return import('@/pages/account/register/result'); 
        }
    }
];

/**
 * 错误页面
 */

const errorPage = [
    {
        path: '/403',
        name: '403',
        meta: {
            title: '403'
        },
        component: () => {
            return import('@/pages/system/error/403'); 
        }
    },
    {
        path: '/500',
        name: '500',
        meta: {
            title: '500'
        },
        component: () => {
            return import('@/pages/system/error/500'); 
        }
    },
    {
        path: '*',
        name: '404',
        meta: {
            title: '404'
        },
        component: () => {
            return import('@/pages/system/error/404'); 
        }
    }
];

// 导出需要显示菜单的
export const frameInRoutes = frameIn;

// 重新组织后导出
export default [
    ...frameIn,
    ...frameOut,
    ...errorPage
];
